package com.wison.quartz.job;

import org.nutz.dao.Dao;
import org.nutz.dao.Sqls;
import org.nutz.dao.entity.Record;
import org.nutz.dao.sql.Sql;
import org.nutz.http.Http;
import org.nutz.ioc.loader.annotation.Inject;
import org.nutz.ioc.loader.annotation.IocBean;
import org.nutz.json.Json;
import org.quartz.Job;
import org.quartz.JobExecutionContext;
import org.quartz.JobExecutionException;

import java.util.HashMap;
import java.util.List;
import java.util.Map;

/**
 * Created by Administrator on 2017/6/3.
 */
@IocBean
public class DepJob implements Job {

    @Inject
    private Dao dao;

    @Inject("java:$conf.get('server_url')")
    private String wsdlurl;

    @Inject("java:$conf.get('dwID')")
    private String dwID;

    @Override
    public void execute(JobExecutionContext jobExecutionContext) throws JobExecutionException {
        try {
            Map<String, Object> parms = new HashMap<String, Object>();
            Sql sql = Sqls.queryRecord("select dep_serial bmid ,dep_name bmmc,dep_name fbmmc,'" + dwID + "' dw from dt_dep ");
            dao.execute(sql);
            List<Record> list = sql.getList(Record.class);
            parms.put("cards", Json.toJson(list));
            String response = Http.post(wsdlurl + "/saveBM.do", parms, 5 * 1000);


        } catch (Exception e) {
            e.printStackTrace();
        }

    }
}
